package cn.dapeng.designPatterns.singleton;

import lombok.Getter;

import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

@Getter
public class HungerSingleton {

    @Getter
    private final static HungerSingleton instance = new HungerSingleton();

    private HungerSingleton() {
    }

    public static void main(String[] args) {
        Set<Integer> set = new CopyOnWriteArraySet<>();
        int testTimes = 100_0000;

        for (int i = 0; i < testTimes; i++) {
            new Thread(() -> {
                set.add(HungerSingleton.getInstance().hashCode());
            }).start();
        }

        System.out.println("size:: " + set.size());
    }
}
